﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using Arcanea.StateEditor;
using Arcanea.PacketEditor;

namespace Arcanea.Editor
{
    public partial class FormMain : Form
    {
        public readonly string FilePaths = Path.Combine(Application.StartupPath, "..\\datas");

        public FormMain()
        {
            InitializeComponent();
            UserControlStateEditor.XMLFilePathState = Path.GetFullPath(Path.Combine(FilePaths, UserControlStateEditor.XMLFileNameState));
            UserControlStateEditor.XMLFilePathPacket = Path.GetFullPath(Path.Combine(FilePaths, UserControlPacketEditor.XMLFileNamePacket));
            UserControlPacketEditor.XMLFilePathPacket = Path.GetFullPath(Path.Combine(FilePaths, UserControlPacketEditor.XMLFileNamePacket));
        }

        private void FormMain_FormClosing(object sender, FormClosingEventArgs e)
        {
            //Sauvegarde XML
            if (tabControlMainForm.SelectedIndex == 0)
            {
                userControlState.SaveState(sender, e);
            }
            else if (tabControlMainForm.SelectedIndex == 1)
            {
                userControlPacket.SaveState(sender, e);
            }
        }

        private void tabControlMainForm_TabIndexChanged(object sender, EventArgs e)
        {
            //Sauvegarde XML
            userControlState.SaveState(sender, null);
            userControlPacket.SaveState(sender, null);
        }
    }
}
